<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="text" class="input1"/>
    </div>
</body>
<script>
    function debounce(fn,time){
    let timer=null;//定义定时器标志
    //返回一个函数
    return function(){
        //清空定时器
        clearTimeout(timer);
        timer=setTimeout(()=>{
            fn.apply(this,...arguments);
        },time)
    }
}
var validate = debounce(function(e) {
    console.log("change", e.target.value)
}, 380);
// 绑定监听
document.querySelector("input").addEventListener('keyup', validate);
</script>
</html>